package com.longcai.piaojia.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/10/14.
 */
@HttpInlet(Conn.RECHARGE_GET)
public class DepositListGet extends BaseAsyGet<DepositListGet.DepositListGetEntity> {

    public String user_id;

    public DepositListGet(AsyCallBack<DepositListGetEntity> asyCallBack) {
        super(asyCallBack);
    }


    @Override
    protected DepositListGetEntity parser(JSONObject object) throws Exception {

        TOAST = object.optString("message");

        if (object.optInt("code") == 200) {

            DepositListGetEntity depositListGetEntity = new DepositListGetEntity();

            depositListGetEntity.wallet = object.optString("wallet");
            depositListGetEntity.privilege = object.optString("privilege");

            JSONArray array = object.optJSONArray("data");

            for (int i = 0; i < array.length(); i++) {

                JSONObject entityObject = array.optJSONObject(i);

                DespoistEntity entity = new DespoistEntity();

                entity.money = entityObject.optString("money");
                entity.present = entityObject.optString("present");

                depositListGetEntity.despoistEntityList.add(entity);

            }


            return depositListGetEntity;
        }

        return null;
    }

    public static class DepositListGetEntity {

        public List<DespoistEntity> despoistEntityList = new ArrayList<>();
        public String wallet;
        public String privilege;

    }

    public static class DespoistEntity {

        public String money, present;

    }



}
